﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            showVideo();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
        private void showVideo()
        {
            string sourceURL = this.textBox1.Text;
            byte[] buffer = new byte[100000];
            int read, total = 0;
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
            //req.Credentials = new NetworkCredential("root", "admin");
            WebResponse resp = req.GetResponse();
            Stream stream = resp.GetResponseStream();
            while ((read = stream.Read(buffer, total, 100)) != 0)
            {
                total += read;
            }
            Bitmap bmp = (Bitmap)Bitmap.FromStream(new MemoryStream(buffer, 0, total));
            pictureBox1.Image = bmp;
        
        }
    }
}
